<template>
  <CocosScene >
    <Main v-if="polyfile" :bkframe="bkframe" :rotframe="rotframe" :rsvframe="rsvframe" :polyfile="polyfile" /> 
  </CocosScene >
</template>

<script>
/* eslint-disable */

import {CocosScene,Node,Sprite} from "../cocos";
import Main from "./Main";
// import Block from "./Block";

export default {
  name: "Scene",
  components: {
    CocosScene,Main,
  },
  data() {
    return {
      bkframe:null,
      rotframe:null,
      rsvframe:null,
      polyfile:null,
    };
  },
  // computed: {
  //   acolor(){
  //     console.log("computed acolor");
  //     return "#00f";
  //   },
  // },
  mounted() {
    this.loadres();
  },
  methods: {
    loadframe(url,cb){
      cc.assetManager.loadRemote(url, (err, tex) => {
        if(!err&&cb){
          cb(new cc.SpriteFrame(tex));
        }
      });
    },
    loadjson(url,cb){
      cc.assetManager.loadRemote(url, (err, asset) => {
        if(!err&&cb){
          cb(asset.json);
        }
      });
    },
    loadres(){
      // 背景
      this.loadframe("./examples/polygon/bk.png",(frame)=>{
        this.bkframe = frame;
      });
      this.loadframe("./examples/polygon/btnRot.png",(frame)=>{
        this.rotframe = frame;
      });
      this.loadframe("./examples/polygon/btnRsv.png",(frame)=>{
        this.rsvframe = frame;
      });

      this.loadjson("./examples/polygon/polyfile.json",(json)=>{
        // console.log("load polyfile",json);
        this.polyfile = json;
      });

    },
  },

};
</script>
